package com.dennisstepp.database;

import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

public class BosculDbAdapter {
	// Database fields
	public static final String KEY_ROWID = " _id";
	public static final String KEY_SIZE = "SizeofWriting";
	public static final String KEY_NAME = "Name";
	public static final String KEY_DESCRIPTION = "Description";
	public static final String KEY_VALUE = "Value";
	public static final String KEY_STATUS = "Status";
	private static final String DATABASE_TABLE = "Boscul";
	private String smallWriting = "\"Small Writing\"";
	private String largeWriting = "\"Large Writing\"";
	private Context context;
	private SQLiteDatabase database;
	private DatabaseHelper dbHelper;

	public BosculDbAdapter(Context context) {
		this.context = context;
	}

	public BosculDbAdapter open() throws SQLException {
		dbHelper = new DatabaseHelper(context);
		database = dbHelper.getWritableDatabase();
		return this;
	}

	public void close() {
		dbHelper.close();
	}

	public Cursor fetchAllSmallBoscul() {
		return database.query(DATABASE_TABLE, new String[] { KEY_ROWID,
				KEY_NAME, KEY_DESCRIPTION, KEY_VALUE, KEY_STATUS },
				KEY_SIZE + "=" + smallWriting, null, null, null, null);
	}

	public Cursor fetchAllLargeBoscul() {
		return database.query(DATABASE_TABLE, new String[] { KEY_ROWID,
				KEY_NAME, KEY_DESCRIPTION, KEY_VALUE, KEY_STATUS }, 
				KEY_SIZE + "=" + largeWriting, null, null, null, null);
	}

}
